//
//  LPDCDetailSecondTableViewCell.m
//  LovingPartyBuilding
//
//  Created by 刘应平 on 17/5/6.
//  Copyright © 2017年 刘应平. All rights reserved.
//

#import "LPDCDetailSecondTableViewCell.h"

@implementation LPDCDetailSecondTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}


/**  145 左图右文字 */
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self layoutUI];
        UIView *under = [UIView new];
        under.backgroundColor = [UIColor themeGrayColor];
        [self addSubview:under];
        under.sd_layout.leftEqualToView(self).bottomEqualToView(self).widthIs([UIScreen zj_screenWith]).heightIs(1.5);
        
    }
    return self;
}


#pragma mark - 界面
- (void)layoutUI{
    [self addSubview:self.livingImageView];
    [self addSubview:self.livingLabel];
    [self addSubview:self.time];
    
    
    
    self.livingImageView.sd_layout
    .topSpaceToView(self,10 * [UIScreen zj_screenHScale])
    .leftSpaceToView(self, 15 * [UIScreen zj_screenWScale])
    .widthIs([UIScreen zj_screenWith] * 0.35)
    .heightIs(95 * [UIScreen zj_screenHScale]);
    
    
    self.livingLabel.sd_layout
    .topSpaceToView(self,10 * [UIScreen zj_screenHScale])
    .leftSpaceToView(self.livingImageView,10 * [UIScreen zj_screenWScale])
    .widthIs([UIScreen zj_screenWith] * 0.65 - 40 * [UIScreen zj_screenWScale])
    .heightIs(20 * [UIScreen zj_screenHScale]);

    self.time.sd_layout
    .rightSpaceToView(self,15 * [UIScreen zj_screenWScale])
    .heightIs(15 * [UIScreen zj_screenHScale])
    .bottomEqualToView(self.livingImageView)
    .leftSpaceToView(self.livingImageView,10 * [UIScreen zj_screenWScale]);
    
}


#pragma mark - 私有方法

- (void)setModel:(LPDCDetailModel *)model{
    _model = model;
    
    self.time.text = model.AUTHOR;
    [self.livingImageView sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",BASEIMAGEURL,model.COVERTHUMBURL]] placeholderImage:PlaceholderImage];
    /**  设置行距  */
   
    self.livingLabel.attributedText = [UILabel setSpaceForLineWithText:model.TITLE lineSpace:4 * [UIScreen zj_screenHScale]];
    if (model.height > 70 * [UIScreen zj_screenHScale]) {
        self.livingLabel.sd_layout.heightIs(70 * [UIScreen zj_screenHScale]);
    }else{
        self.livingLabel.sd_layout.heightIs(model.height);
    }
    [self.livingLabel updateLayout];
    
}


#pragma mark - setter


- (UILabel *)livingLabel{
    if (!_livingLabel) {
        _livingLabel = ({
            UILabel *label = [UILabel new];
            label.textAlignment = NSTextAlignmentLeft;
            label.textColor = [UIColor textBlackColor];
            label.numberOfLines = 0;
            label.font = [UIFont systemFontOfSize:15 * [UIScreen zj_textFontScale]];
            label;
        });
    }
    return _livingLabel;
}


- (UILabel *)time{
    if (!_time) {
        _time = ({
            UILabel *label = [UILabel new];
            label.textAlignment = NSTextAlignmentLeft;
            label.textColor = [UIColor textGrayColor];
            label.backgroundColor = [UIColor clearColor];
            label.font = [UIFont systemFontOfSize:14 * [UIScreen zj_textFontScale]];
            label;
        });
    }
    return _time;
}

- (UIImageView *)livingImageView{
    if (!_livingImageView) {
        _livingImageView = [UIImageView new];
    }
    return _livingImageView;
    
}
@end
